<?php

/**
 * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
 * Copyright (c) 2010 Mr. Ynk: http://www.mrynk.nl
 */

/**
 * @author Michel Ypma: michel@mrynk.nl
 */

require_once 'schema/SchemaUtils.php';

class BuildManager
{

    private $__loader;

    public function loadSchemas( $defs )
    {
        if ( in_array( 'all' , $defs ) )
        {
            $schemas = SchemaUtils::allSchemas();
        } else {
            $schemas = SchemaUtils::checkSchemas( $defs );
        }

        $this->__loader = new SchemaLoader( $schemas );
    }

    public function buildClasses( $_classes )
    {
        $classes = array();
        if ( !empty( $_classes ) ) {
            foreach( $_classes as $_class )
                $classes[] = $this->__loader->getClassByName( $_class );
        } else {
            $classes = $this->__loader->getClasses();
        }
        foreach( $classes as $class )
        {
            foreach( $class['language'] as $lang )
			{
				if ( strlen($lang['name']) < 5 )
					$lang['name'] = $lang['name'].str_repeat(' ', 5 - strlen($lang['name']) );
                MytoCLI::output( ':: BUILDING CLASS: '. $lang['name'] .'-> '. $class['class']['name'] );
            }

            $builder = new ClassBuilder( $class );
            $builder->write();
        }
    }

}
?>